"""
这是一个logging模块的简单演示。
2021/3/18
"""
import logging

"""
这是在所有最开始的地方指定的日志配置。

filename: 写入日志文件，不指定filename则会将日志输出到控制台上。
filemode: w（覆盖写入），默认是a（追加）。
format: 输出日志的格式，%(level)s日志级别，%(message)s日志内容，%(asctime)s当前时间。
level: 日志级别。
datefmt: 使用%(asctime)s输出的时间格式，格式与time.strftime()相同。
    %Y  Year with century as a decimal number.
    %m  Month as a decimal number [01,12].
    %d  Day of the month as a decimal number [01,31].
    %H  Hour (24-hour clock) as a decimal number [00,23].
    %M  Minute as a decimal number [00,59].
    %S  Second as a decimal number [00,61].
    %z  Time zone offset from UTC.
    %a  Locale's abbreviated weekday name.
    %A  Locale's full weekday name.
    %b  Locale's abbreviated month name.
    %B  Locale's full month name.
    %c  Locale's appropriate date and time representation.
    %I  Hour (12-hour clock) as a decimal number [01,12].
    %p  Locale's equivalent of either AM or PM.
"""
logging.basicConfig(filename='d:\\test.log', filemode='w', format='%(asctime)s %(level)s %(message)s', level='INFO', datefmt='%H:%M:%S')

"""
使用各种级别输出日志。

级别有：debug, info, warning, error, critical共5种。
"""
logging.info('')
logging.warning('')
logging.error('')
logging.debug('')
logging.critical('')


"""
提供异常原始信息，包括出现异常的代码和行号。
"""
logging.info('', exc_info=True)


def example():
    logging.basicConfig(filename='')
    logging.info('test')